import { request } from '@/utils/request';
// 主页相关的接口
/**
 * 根据用户id查询该用户最近访问文件
 * @returns {Promise<ApiRet>}
 */
const searchRecentVisitDoc =()=>{
    const userId = localStorage.getItem('userId');
    return request({
        url: `/doc/getRecentVisitDoc`,
        method: "GET",
    })
}
/**
 * 根据文档名称查询文档
 * @param {string} name 文档名称
 */
const searchDocByName = ({name})=>{
    const params = {
        name
    }
    return request({
        url: '/doc/searchDocList',
        method: "GET",
        params
    })
}
/**
 * 根据文档名称搜索最近访问文档
 * @param {string} name 文档名称
 */
const searchRecentlyAccessDocByDocName = ({docName})=>{
    const params = {
        docName
    }
    return request({
        url: `/doc/searchRecentlyAccessDocByDocName/${docName}`,
        method: "GET",
        params
    })
}

/**
 * 校验文档分享码并获取文档详情
 * @returns {Promise<ApiRet>}
 */
export const verifyDocShareCode = (shareCode) => {
    return request({
        url: '/doc/verifyDocShareCode',
        method: 'GET',
        params: {
            shareCode
        }
    });
};

export {
    searchRecentVisitDoc,
    searchDocByName,
    searchRecentlyAccessDocByDocName
}